package one.stand.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import one.stand.aop.ApiController;
import one.stand.model.ResultModel;
import one.stand.request.AppointmentRequest;
import one.stand.request.ProductsRequest;
import one.stand.request.ProductsTypeRequest;
import one.stand.response.AppointmentResponse;
import one.stand.response.ProductsResponse;
import one.stand.response.ProductsTypeResponse;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 产品信息管理
 * @author Administrator
 */
@RestController
@RequestMapping("userApi/products")
@Api(description = "产品信息管理",tags="产品信息管理")
public class ProductsController extends BaseController {

    @PostMapping("/getProductsCount")
    @ApiOperation(value = "根据公司ID查询预约管理中预约列表数和产品管理数")
    @ApiImplicitParam(name = "companyId", value = "公司id", required = true, paramType = "Integer")
    @ApiController(isLogin = true, paramClass = AppointmentRequest.class )
    public ResultModel<Map<String, Object>> getProductsCount(@RequestAttribute AppointmentRequest request) {
        return userFegin.getProductsCount(request);
    }

    @PostMapping("/selectProductsTypeList")
    @ApiOperation(value = "查询公司预约商品类型（下拉框显示）")
    @ApiImplicitParam(name = "companyId", value = "公司id", required = true, paramType = "Integer")
    @ApiController(isLogin = false, paramClass = ProductsTypeRequest.class )
    @Deprecated
    public ResultModel<List<ProductsTypeResponse>> selectProductsTypeList(@RequestAttribute ProductsTypeRequest request) {
        return userFegin.selectProductsTypeList(request);
    }

    @PostMapping("/selectProductsTypeList/V2")
    @ApiOperation(value = "查询公司预约商品类型（下拉框显示）")
    @ApiImplicitParam(name = "companyId", value = "公司id", required = true, paramType = "Integer")
    @ApiController(isLogin = true, paramClass = ProductsTypeRequest.class )
    public ResultModel<List<ProductsTypeResponse>> selectProductsTypeListV2(@RequestAttribute ProductsTypeRequest request) {
        return userFegin.selectProductsTypeList(request);
    }

    @PostMapping("/selectProductsTypePage")
    @ApiOperation(value = "分页查询公司预约商品类型")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "pageNum", value = "当前页", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "productsTypeName", value = "预约商品类型名称", paramType = "String"),
            @ApiImplicitParam(name = "companyId", value = "公司id", required = true, paramType = "Integer")
    })
    @ApiController(isLogin = true, paramClass = ProductsTypeRequest.class )
    public ResultModel<Map<String, Object>> selectProductsTypePage(@RequestAttribute ProductsTypeRequest request) {
        return userFegin.selectProductsTypePage(request);
    }

    @PostMapping("/selectProductsType")
    @ApiOperation(value = "查询公司预约商品类型（包含类型下的商品信息）")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "companyId", value = "公司id", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "productsTypeName", value = "预约商品类型名称", paramType = "String"),
    })
    @ApiController(isLogin = true, paramClass = ProductsTypeRequest.class )
    public ResultModel<List<ProductsTypeResponse>> selectProductsType(@RequestAttribute ProductsTypeRequest request) {
        return userFegin.selectProductsType(request);
    }

    @PostMapping("/selectProductsPage")
    @ApiOperation(value = "分页查询公司预约商品信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "pageNum", value = "当前页", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "companyId", value = "公司id", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "productsTypeId", value = "预约商品类型id（不传查询全部商品）", paramType = "Integer"),
    })
    @ApiController(isLogin = false, paramClass = ProductsRequest.class )
    @Deprecated
    public ResultModel<Map<String, Object>> selectProductsPage(@RequestAttribute ProductsRequest request) {
        return userFegin.selectProductsPage(request);
    }

    @PostMapping("/selectProductsPage/V2")
    @ApiOperation(value = "分页查询公司预约商品信息")
    @ApiImplicitParams({
                    @ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, paramType = "Integer"),
                    @ApiImplicitParam(name = "pageNum", value = "当前页", required = true, paramType = "Integer"),
                    @ApiImplicitParam(name = "companyId", value = "公司id", required = true, paramType = "Integer"),
                    @ApiImplicitParam(name = "productsTypeId", value = "预约商品类型id（不传查询全部商品）", paramType = "Integer"),
    })
    @ApiController(isLogin = true, paramClass = ProductsRequest.class )
    public ResultModel<Map<String, Object>> selectProductsPageV2(@RequestAttribute ProductsRequest request) {
        return userFegin.selectProductsPage(request);
    }

    @PostMapping("/getProductsInfo")
    @ApiOperation(value = "查询公司预约商品信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "productsId", value = "预约商品id", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = false, paramClass = ProductsRequest.class )
    @Deprecated
    public ResultModel<ProductsResponse> getProductsInfo(@RequestAttribute ProductsRequest request) {
        return userFegin.getProductsInfo(request);
    }

    @PostMapping("/getProductsInfo/V2")
    @ApiOperation(value = "查询公司预约商品信息")
    @ApiImplicitParams({
                    @ApiImplicitParam(name = "productsId", value = "预约商品id", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true, paramClass = ProductsRequest.class )
    public ResultModel<ProductsResponse> getProductsInfoV2(@RequestAttribute ProductsRequest request) {
        return userFegin.getProductsInfo(request);
    }


    @PostMapping("/selectAppointmentPage")
    @ApiOperation(value = "分页查询预约列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "pageNum", value = "当前页", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "state", value = "1进行中，2已完成，3已取消", paramType = "Integer"),
            @ApiImplicitParam(name = "createTimes", value = "下单时间", paramType = "String"),
            @ApiImplicitParam(name = "startTimes", value = "预约开始时间", paramType = "String"),
            @ApiImplicitParam(name = "endTimes", value = "预约结束时间", paramType = "String"),
            @ApiImplicitParam(name = "companyId", value = "公司id", required = true,paramType = "Integer"),
    })
    @ApiController(isLogin = true, paramClass = AppointmentRequest.class )
    public ResultModel<Map<String, Object>> selectAppointmentPage(@RequestAttribute AppointmentRequest request) {
        return userFegin.selectAppointmentPage(request);
    }

    @PostMapping("/getAppointmentInfo")
    @ApiOperation(value = "查询预约列表详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "appointmentId", value = "预约id", required = true,paramType = "Integer"),
    })
    @ApiController(isLogin = true, paramClass = AppointmentRequest.class )
    public ResultModel<AppointmentResponse> getAppointmentInfo(@RequestAttribute AppointmentRequest request) {
        return userFegin.getAppointmentInfo(request);
    }

    @PostMapping("/insertAppointment")
    @ApiOperation(value = "新增预约订单")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "productsId", value = "产品id", required = true,paramType = "Integer"),
            @ApiImplicitParam(name = "companyId", value = "公司id", required = true,paramType = "Integer"),
            @ApiImplicitParam(name = "name", value = "姓名", required = true,paramType = "String"),
            @ApiImplicitParam(name = "phone", value = "电话", required = true,paramType = "String"),
            @ApiImplicitParam(name = "serviceType", value = "服务类型：1到店服务，2上门服务", required = true,paramType = "Integer"),
            @ApiImplicitParam(name = "startTimes", value = "预约开始时间（yyyy-mm-dd hh:mm）", required = true,paramType = "String"),
            @ApiImplicitParam(name = "endTimes", value = "预约结束时间（yyyy-mm-dd hh:mm）", required = true,paramType = "String"),
            @ApiImplicitParam(name = "remark", value = "用户备注", paramType = "String"),
    })
    @ApiController(isLogin = true, paramClass = AppointmentRequest.class )
    public ResultModel<Boolean> insertAppointment(@RequestAttribute AppointmentRequest request) {
        return userFegin.insertAppointment(request);
    }

    @PostMapping("/updAppointmentState")
    @ApiOperation(value = "修改预约订单状态")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "appointmentId", value = "预约id", required = true,paramType = "Integer"),
            @ApiImplicitParam(name = "state", value = "1进行中，2已完成，3已取消", required = true,paramType = "Integer"),
            @ApiImplicitParam(name = "applyRemark", value = "审核备注", paramType = "String"),
    })
    @ApiController(isLogin = true, paramClass = AppointmentRequest.class )
    public ResultModel<Boolean> updAppointmentState(@RequestAttribute AppointmentRequest request) {
        return userFegin.updAppointmentState(request);
    }

}
